﻿using System.Collections.Generic;
using Moonwish.Core;
using Moonwish.SchoolDorms.DataAccess.Interface;
using Moonwish.SchoolDorms.DataAccess.SqlServer.BuildCmd;
using Moonwish.SchoolDorms.DataEntity;

namespace Moonwish.SchoolDorms.DataAccess.SqlServer
{
    public class BuildDA : IBuildDA
    {
        public void Add(List<V_SCD_Build> items, string userId)
        {
            using (var context = new TDormSettingsContainer())
            {
                new AddCommand(context, items, userId).Execute();
            }
        }

        public void Update(List<V_SCD_Build> items, string userId)
        {
            using (var context = new TDormSettingsContainer())
            {
                new UpdateCommand(context, items, userId).Execute();
            }
        }

        public void Delete(List<string> ids, string userId)
        {
            using (var context = new TDormSettingsContainer())
            {
                new DeleteCommand(context, ids, userId).Execute();
            }
        }

        public List<V_SCD_Build> Query(Request request)
        {
            using (var context = new TDormSettingsContainer())
            {
                return new QueryDataCommand(context, request).Execute();
            }
        }
    }
}
